package de.ama.crawler;

import de.ama.util.Util;

import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: ama
 * Date: 14.02.11
 * Time: 18:01
 * To change this template use File | Settings | File Templates.
 * <p/>
 * movie db key: 741b59377536205e7d8960e441d68c06
 */
public class Crawler {
    private File dir;

    public Crawler(File dir) {
        this.dir = dir;
        readDir(dir);
    }

    private void init(String dirName) {
    }

    private void readDir(File dir) {
        if (dir.isDirectory()) {
            File[] files = dir.listFiles();
            for (File file : files) {
                if (file.isDirectory()) {
                    readDir(file);
                } else {
                    String ext = Util.getFileExtension(file);
                    if (ext!= null && ext.length()>0 && Config.get().getTypes().contains(ext.toLowerCase())) {
                        Store.get().addMovie(file);
                    }
                }
            }
        }
    }

}
